import { Injectable } from "@angular/core";
import { LoaderComponent } from "./shared/components/loader/loader.component";
import { SpinnerComponent } from "./shared/components/spinner/spinner.component";

@Injectable()
export class AppService {
    private static loader: LoaderComponent;
    private static spinner: SpinnerComponent;

    /**
     * Hides spinner and loader mask
     * @param error True if hidden because error and false because loading has finished
     */
    public static finishLoading(error: boolean){
        this.loader.end();
        this.spinner.hide();       
    }

    /**
     * Set loader ans spinner variables
     * @param loader loader component
     * @param spinner spinner component
     */
    public static set(loader: LoaderComponent, spinner: SpinnerComponent){        
        this.loader = loader;
        this.spinner = spinner;          
    }
}